//获得学历的ajax
$.ajax({
    type: "get",
    url: "/education",
    success(data) {
        //把json格式的字符串转为json对象
        let dataObjs = JSON.parse(data);
        //声明一个字符串来拼接option
        let str = `<option value="0">----请选择学历------</option>`;
        for (let i = 0; i < dataObjs.length; i++) {
            str += `<option value="${dataObjs[i].id}">${dataObjs[i].name}</option>`;
        };
        // console.log(str) 
        document.getElementById("education").innerHTML = str;

    }
});
//获取班级的ajax
$.ajax({
    type: "get",
    url: "/clazz",
    success(data) {
        //把json格式的字符串转为json对象
        let dataObjs = JSON.parse(data).classList;
        //声明一个字符串来拼接option
        let str = `<option value="0">----请选择学历------</option>`;
        for (let i = 0; i < dataObjs.length; i++) {
            str += `<option value="${dataObjs[i].id}">${dataObjs[i].name}</option>`;
        };
        // console.log(str)
        document.getElementById("clazz").innerHTML = str;

    }
});
//获取学生信息的ajax
$.ajax({
    type: "get",
    url: "/student",
    success(data) {
        let dataObjs = JSON.parse(data);
        let str = ``;
        for (let i = 0; i < dataObjs.students.length; i++) {
            str +=
                `<tr>
                <td>${dataObjs.students[i].id}</td>
                <td>${dataObjs.students[i].name}</td>
                <td>${dataObjs.students[i].age}</td>
                <td>${dataObjs.students[i].gender}</td>
                <td>${dataObjs.students[i].class}</td>
                </tr>`;
        };

        document.getElementById("showData").innerHTML = str;
    }
});